<template>
    <view class="container">
        <view class="task_type_list">
            <scroll-view scroll-x class="tab-h" :scroll-into-view="'tab_'+positionTab" scroll-with-animation='true'>
              <view  v-for="(item,index) in taskStateList" :key="index" @tap='bindTypeItem(index)' :id="'tab_'+item.id" class='tab-item' :style="{color:positionTab==index?defaultColor:'',}">
                {{item.name}}
                <text class="active_border" :style="{borderBottom:'4rpx solid '+defaultColor}" v-if="positionTab==index"></text>
              </view>
            </scroll-view>
        </view>
        <view class="task_list" v-if="taskList&&taskList.length!=0">
            <view class="task_item" v-for="(item,index) in taskList" :key="index" :data-url="'task_detail.html?taskId='+item.task.id" @tap="tolinkUrl">
                <view class="task_item_top">
                    <text class="task_type_tag" :style="{background:defaultColor}" v-if="item.task.topOrder>0">顶</text>
                    <text class="task_type_tag" :style="{background:defaultColor}" v-if="item.task.taskMode==1">抢单</text>
                    <text class="task_type_tag" :style="{background:defaultColor}" v-if="item.task.taskMode==2">预选</text>
                    <text class="task_item_price" :style="{color:defaultColor}" v-if="item.task.priceMode==0">免费</text>
                    <text class="task_item_price" :style="{color:defaultColor}" v-if="item.task.priceMode==1">可议价</text>
                    <text class="task_item_price" :style="{color:defaultColor}" v-if="item.task.priceMode==2">￥{{item.taskPrice}}</text>
                    <text class="task_item_name">{{item.taskName}}</text>
                    <image class="hb_block" v-if="item.task.tipPrice" src="https://image1.sansancloud.com/xianhua/2020_5/8/10/20/37_663.jpg?x-oss-process=style/preview_120"></image>
                </view>
                <view class="task_item_content">
                    {{item.task.content||''}}
                </view>
                <scroll-view class='tags_content' scroll-x v-if="item.tags">
                  <text class='tags_item' :style="{background:defaultColor+22,color:defaultColor}" v-for='(item,index) in item.managerTagArray' :key='index'>{{item}}</text>
                  <text class='tags_item' style="border: 1rpx solid #eee;" v-for='(item,index) in item.tagArray' :key='index'>{{item}}</text>
                </scroll-view>
                <view class="task_item_bottom">
                    <!-- <view class="task_item_attend_count">终选<text :style="{color:defaultColor,margin:'0 4rpx'}">{{item.task.taskServantCount||0}}</text>人</view> -->
                    <view class="task_item_state">
                        <text class="task_item_state_text" v-if="item.status==0">挑选作品中</text>
                        <text class="task_item_state_text" v-if="item.status==1">等待签订合同</text>
                        <text class="task_item_state_text" v-if="item.status==2">合同签订完毕</text>
                        <text class="task_item_state_text" v-if="item.status==4">任务进行中</text>
                        <text class="task_item_state_text" v-if="item.status==5">任务结束</text>
                        <text class="task_item_state_text" v-if="item.status==6">支付完成</text>
                        <text class="task_item_state_text" v-if="item.status==7">已作废</text>
                        <text class="task_item_state_text" v-if="item.status==8">已评价</text>
                    </view>
                    <text class="task_item_attend_count">{{item.attendedTime}}</text>
                </view>
                <view class="task_item_fun_block">
                    <!-- ||item.taskStatus>=3  v-if="item.status==0||item.status==4"-->
                    <view class="need_pay_price" v-if="item.task.priceMode==1&&item.status>=2" :style="{color:defaultColor}">议价结果：￥{{item.needConfirmChangeTaskPrice==1?item.prechangeTaskPrice:item.needPayPrice}}</view>
                    <view class="need_pay_price" v-else></view>
                    <view class="task_item_fun_list">
                        <view class="task_item_fun_item" @click.stop="sureHandleTaskFun(item.id,item.task.id)" v-if="item.status==0">
                            <text class="task_item_fun_item_text">取消参与</text>
                        </view>
                        <block v-if="item.processInstanceId>0">
                            <view class="task_item_fun_item" @click.stop="sureHandleTaskFun(item.id,item.task.id,'toProcess',item)" v-if="item.status==4">
                                <text class="task_item_fun_item_text">执行任务</text>
                            </view>
                        </block>
                        <block v-else>
                            <view class="task_item_fun_item" @click.stop="sureHandleTaskFun(item.id,item.task.id,'finish')" v-if="item.status==4">
                                <text class="task_item_fun_item_text">完成任务</text>
                            </view>
                        </block>
                        <view class="task_item_fun_item" @click.stop="sureHandleTaskFun(item.id,item.task.id,'confirmChangePrice')" v-if="item.status>1 && item.status<5&&item.needConfirmChangeTaskPrice==1">
                            <text class="task_item_fun_item_text">确认价格</text>
                        </view>
                        <view class="task_item_fun_item" @click.stop="sureHandleTaskFun(item.id,item.task.id,'comment',item)" v-if="item.status==6&&!item.taskerCommentId">
                            <text class="task_item_fun_item_text">评价</text>
                        </view>
                        <view class="task_item_fun_item" v-if="item.taskerCommentId">
                            <text class="task_item_fun_item_text">已评价</text>
                        </view>
                        <!-- <view class="task_item_fun_item" @click.stop="sureHandleTaskFun(item.id,item.task.id,'endPay')" v-if="item.payedStatus==0&&item.needPayedType==2">
                            <text class="task_item_fun_item_text">支付尾款</text>
                        </view>
                        <view class="task_item_fun_item" @click.stop="sureHandleTaskFun(item.id,item.task.id,'perPay')" v-if="item.payedStatus==0&&item.needPayedType==1">
                            <text class="task_item_fun_item_text">预付订单</text>
                        </view> -->
                        <!-- <view class="task_item_fun_item" @click.stop="sureHandleTaskFun('check',item.id)" v-if="item.taskStatus>=3">
                            <text class="task_item_fun_item_text">参与列表</text>
                        </view> -->
                    </view>
                </view>
            </view>
        </view>
        <view class="noproduct" v-else>
          <image mode="widthFix" src='https://image1.sansancloud.com/xianhua/2019_12/16/15/54/55_950.jpg?x-oss-process=style/preview_120'></image>
          <text>没有相关任务</text>
        </view>
        <!-- 填写表单弹窗动画 -->
        <view class='zhezhao' v-if="showCommentState" @tap='closeZhezhao'></view>
        <view class='popupFormDetail' :animation="animationData">
          <view class='form_title' >
            <text ></text>
            <text>请填写以下信息</text>
            <image class='close_popup_icon' src='https://image1.sansancloud.com/xianhua/2019_7/31/15/25/40_755.jpg?x-oss-process=style/preview_120' @click='closeZhezhao'></image>
          </view>
          <scroll-view scroll-y  style='max-height:700rpx'>
            <view v-if="sendOptionData&&sendOptionData.customFormId&&showCommentState">
               <form-detail-component id="submitTaskForm" :receiveData="sendOptionData" :showTitle="true" :showBtn="false" @sendDataFun="getDataFun"></form-detail-component><!-- 弹窗-->
            </view>
            <view class="comments_other_block">
                <view class="comments_other_item" style="flex-direction: column">
                    <text class="comments_other_item_title" style="margin-bottom: 10rpx;">评论内容</text>
                    <textarea class="comments_textarea" maxlength="-1" auto-height="" @input="saveSearchValue" placeholder='请输入您的评论内容'></textarea>
                </view>
                <view class="comments_other_item" style="align-items: center">
                    <text class="comments_other_item_title">评分等级</text>
                    <view class="star_container">
                      <view class="star" data-scroll="1" @tap="productScroll">
                        <block v-if="otherCommentData.pingfen > 0"><image src="https://image1.sansancloud.com/naifen/2019_5/31/17/7/11_803.jpg?x-oss-process=style/preview_120"></image></block>
                        <block v-else><image src="https://image1.sansancloud.com/naifen/2019_5/31/17/7/11_828.jpg?x-oss-process=style/preview_120"></image></block>
                      </view>
                      <view class="star" data-scroll="2" @tap="productScroll">
                        <block v-if="otherCommentData.pingfen > 1"><image src="https://image1.sansancloud.com/naifen/2019_5/31/17/7/11_803.jpg?x-oss-process=style/preview_120"></image></block>
                        <block v-else><image src="https://image1.sansancloud.com/naifen/2019_5/31/17/7/11_828.jpg?x-oss-process=style/preview_120"></image></block>
                      </view>
                      <view class="star" data-scroll="3" @tap="productScroll">
                        <block v-if="otherCommentData.pingfen > 2"><image src="https://image1.sansancloud.com/naifen/2019_5/31/17/7/11_803.jpg?x-oss-process=style/preview_120"></image></block>
                        <block v-else><image src="https://image1.sansancloud.com/naifen/2019_5/31/17/7/11_828.jpg?x-oss-process=style/preview_120"></image></block>
                      </view>
                      <view class="star" data-scroll="4" @tap="productScroll">
                        <block v-if="otherCommentData.pingfen > 3"><image src="https://image1.sansancloud.com/naifen/2019_5/31/17/7/11_803.jpg?x-oss-process=style/preview_120"></image></block>
                        <block v-else><image src="https://image1.sansancloud.com/naifen/2019_5/31/17/7/11_828.jpg?x-oss-process=style/preview_120"></image></block>
                      </view>
                      <view class="star" data-scroll="5" @tap="productScroll">
                        <block v-if="otherCommentData.pingfen > 4"><image src="https://image1.sansancloud.com/naifen/2019_5/31/17/7/11_803.jpg?x-oss-process=style/preview_120"></image></block>
                        <block v-else><image src="https://image1.sansancloud.com/naifen/2019_5/31/17/7/11_828.jpg?x-oss-process=style/preview_120"></image></block>
                      </view>
                    </view>
                </view>
            </view>
            </scroll-view>
        </view>
        <view v-if="sendOptionData&&showCommentState" class='submitBtn' :style='{background:defaultColor}' @click='submitData'>
          <text>提交评论</text>
        </view>
    </view>
</template>

<script>
import { socketFun } from "../../wxcomponents/public/json2Form";
export default {
  data() {
    return {
      taskList:null,
      taskTypeList:[],
      setting:null,
      positionTab:0,
      listPage:{
          page: 1,
          pageSize: 20,
          totalSize: 0,
          state:-1
      },
      taskStateList:[
          {name:'全部',state:-1},
          {name:'待挑选',state:0},
          {name:'签订完毕',state:2},
          {name:'服务中',state:4},
          {name:'待验收',state:5},
          {name:'已完成',state:6},
      ],
      secondColor:'',
      defaultColor:'',
      showCommentState:false,
      otherCommentData:{commentStr:'',pingfen:5},
      curAttendUserData:null,
      animationData:null,
      sendOptionData:null,
    };
  },
  props: {},

  /*onload*/
  onLoad: function (options) {
    let that=this;
    console.warn("======onLoad:options======", options, getApp().globalData.setting);
    // that.getTypeData();
    that.getData(that.listPage,'upload');
  },
  onReady: function () {
    
  },
  onShow: function () {
    let that=this;
	that.setData({
        setting:getApp().globalData.setting,
        defaultColor:getApp().globalData.setting.platformSetting.defaultColor,
        secondColor:getApp().globalData.setting.platformSetting.secondColor,
       })
  },
  /* 分享 app.js862行*/
  onShareAppMessage: function () {
    console.log(getApp().globalData.miniIndexPage);
    return getApp().globalData.shareForFx2(getApp().globalData.miniIndexPage);
  },
  onPullDownRefresh: function () {
    let that = this; // 下拉刷新的时候首先判断存不存在tab
    console.log("下拉");
    that.listPage.page=1
    that.getData(that.listPage);
    wx.stopPullDownRefresh();
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    console.log('===onReachBottom====');
    let that = this
    if (that.listPage.totalSize > that.listPage.page * that.listPage.pageSize) {
      that.listPage.page++
      that.getData(that.listPage,'upload');
    }else{
        wx.showToast({
          title: "到底了~",
          image: '/wxcomponents/images/icons/tip.png',
          duration: 1000
        });
    }
  },
  methods: {
    /* 商品评分 */
    productScroll: function (e) {
      let that = this;
      let otherCommentData = that.otherCommentData;
      let scoll = e.currentTarget.dataset.scroll;
      otherCommentData.pingfen = scoll;
      that.setData({
        otherCommentData: otherCommentData
      });
      console.log("==productScroll===",otherCommentData,that.otherCommentData)
    },
    saveSearchValue:function(e){
      let that = this;
      let otherCommentData = that.otherCommentData;
      let commentStr = e.detail.value;
      otherCommentData.commentStr = commentStr;
      this.setData({
        otherCommentData: otherCommentData
      })
      console.log("==saveSearchValue===",otherCommentData,that.otherCommentData)
    },
    sureHandleTaskFun:function(itemId,taskId,state,itemData){
        let that=this;
        let title='您确定要取消该任务吗？'
        if(state=='finish'){
           title='您确定要完成该任务吗？' 
        }else if(state=='endPay'){
           title='您确定要支付尾款吗？' 
        }else if(state=='perPay'){
           title='您确定要预付订单吗？' 
        }else if(state=='confirmChangePrice'){
           title='您确定要确认该价格吗？' 
        }else if(state=='toProcess'){
           title='您确定要执行该任务吗？' 
        }else if(state=='comment'){
            that.curAttendUserData=itemData
            that.setData({curAttendUserData:itemData})
            that.showCommentFun();
           return
        }
        wx.showModal({
          title: '提示',
          content: title,
          success (res) {
            if (res.confirm) {
              console.log('用户点击确定')
              if(state=='finish'){
                that.finishTaskFun(itemId,taskId)
              }else if(state=='endPay'||state=='perPay'){
                  that.createTaskOrderFun(state,itemId,taskId)
              }else if(state=='confirmChangePrice'){
                  that.confirmChangeUserTaskPriceFun(itemId,taskId)
              }else if(state=='toProcess'){
                  let url='process_list.html?processInstanceId='+itemData.processInstanceId;
                  that.tolinkUrl(url)
              }else{
                that.cancelTaskFun(itemId,taskId)
              }
            } else if (res.cancel) {
              console.log('用户点击取消')
            }
          }
        })
    },
    showCommentFun:function(){
        console.log("===showCommentFun===",)
        let that=this;
        that.animationDataFun('commentServant')
    },
    //添加评论
    commentInput: function (formId) {
      console.log("===sendComments==", formId);
      var that = this;
      let data = {
        commentType:11,
        commitId:formId||0,
        itemId: that.curAttendUserData.id,
        customFormId:that.curAttendUserData.commentCustomFormId||0,
        commentTargetType:16,
        targetId:that.curAttendUserData.belongPlatformUserId,
      };
      data=Object.assign({},data,that.otherCommentData)
      console.log('文本输入框: input_value :', data);
      let customIndex = getApp().globalData.AddClientUrl("/wx_comment_target.html", data, 'post');
      wx.request({
        url: customIndex.url,
        data: customIndex.params,
        header: getApp().globalData.headerPost,
        method: 'POST',
        success: function (res) {
          that.closeZhezhao();
          that.otherCommentData={commentStr:'',pingfen:5},
          console.log('==res===', res);
          if (res.data.errcode == 0) {
              for(let i=0;i<that.taskList.length;i++){
                  if(that.taskList[i].id==res.data.relateObj.commentItemId){
                      that.$set(that.taskList[i],'taskerCommentId',res.data.relateObj.id)
                  }
              }
            wx.showToast({
              title: "评论成功",
              icon: 'success',
              duration: 2000
            });
          } else {
            wx.showToast({
              title: "评论失败",
              icon: "none",
              duration: 2000
            });
          }
        }
      });
    },
    animationDataFun:function(type){
        let that=this;
        let showCommentState=!that.showCommentState;
        that.setData({
          sendOptionData: that.curAttendUserData.commentCustomFormId?null:{ customFormId: that.curAttendUserData.commentCustomFormId||0},
          showCommentState: showCommentState,
        })
        console.log("showCommentState",showCommentState,that.sendOptionData)
        let animation = wx.createAnimation({
          duration: 400,
          timingFunction: 'ease',
        })
        animation.bottom('100rpx').step()
        that.setData({
          animationData: animation.export(),
        })
    },
    submitData:function(){
        let that=this;
        if(!that.sendOptionData.customFormId){
            that.commentInput()
        }else{
            that.selectComponent("#submitTaskForm").formSubmit();
        }
    },
    getDataFun: function (e) {
      let that = this;
      console.log("===getDataFun===", e, e.detail.formId)
      that.commentInput(e.detail.formId)
    },
    closeZhezhao:function(){
      console.log("======closeZhezhao=========")
      let that=this;
      this.setData({ showCommentState:false })
      let animation = wx.createAnimation({
        duration: 400,
        timingFunction: 'ease',
      })
      animation.bottom('-600rpx').step()
      let setData = animation.export()
      this.setData({
        animationData: setData,
      })
    },
    confirmChangeUserTaskPriceFun:function(id,taskId){
        let that = this
        let params={
            taskId:taskId,
            taskAttendId:id,
        }
        console.log("===params==",params)
        var customIndex = getApp().globalData.AddClientUrl("/wx_confirm_change_task_attended_price.html", params)
        getApp().globalData.showToastLoading('loading', true)
        wx.request({
          url: customIndex.url,
          header: getApp().globalData.header,
          success: function (res) {
            wx.hideLoading()
            console.log(res.data)
            let data=res.data.relateObj;
            if(res.data.errcode==0){
                wx.showToast({
                  title: "操作成功",
                  icon:'success',
                  duration: 1000
                });
                for(let i=0;i<that.taskList.length;i++){
                    if(that.taskList[i].id==id){
                        let curItemData=JSON.parse(JSON.stringify(that.taskList[i]));
                        curItemData.needConfirmChangeTaskPrice=data.needConfirmChangeTaskPrice
                        curItemData.needPayPrice=data.needPayPrice
                        curItemData.prechangeTaskPrice=data.prechangeTaskPrice
                        that.taskList.splice(i,1,curItemData)
                    }
                }
            }else{
                wx.showToast({
                  title: res.data.errMsg,
                  image: '/wxcomponents/images/icons/tip.png',
                  duration: 1000
                });
            }
            wx.hideLoading()
          },
          fail: function (res) {
            console.log("fail")
            wx.hideLoading()
            getApp().globalData.loadFail()
          }
        })
    },
    // createTaskOrderFun: function (state,itemId,taskId) {
    //   var that = this;
    //   let wxChatPayParam = {
    //     payType: 3,
    //     taskId:taskId,
    //     taskAttendId:itemId
    //   };
    //   let reqUrl="/wx_create_task_attend_prepay_order.html";
    //   if(state=='endPay'){
    //     reqUrl="/wx_create_task_attend_endpay_order.html";
    //   }
    //   let customIndex = getApp().globalData.AddClientUrl(reqUrl, wxChatPayParam, 'post');
    //   wx.request({
    //     url: customIndex.url,
    //     data: customIndex.params,
    //     header: getApp().globalData.headerPost,
    //     method: 'POST',
    //     success: function (res) {
    //       console.log(res.data); //这里拿到订单数据
    //       //下面应该吊起支付
    //       console.log(res.data);
    //       let orderNo = res.data.relateObj.orderNo;
    //       if(res.data.errcode==0){
    //         // that.payByWechat(orderNo);
    //         let url='edit_order.html?orderNo='+orderNo;
    //         that.tolinkUrl(url)
    //       }
    //     },
    //     fail: function () {},
    //     complete: function () {
    //     }
    //   });
    // },
    // payByWechat: function (orderNo) {
    //   var that = this;
    //   let loginUser = getApp().globalData.loginUser;
    //   console.log(loginUser);
    //   let wxChatPayParam = {
    //     openid: loginUser.platformUser.miniOpenId,
    //     orderNo: orderNo,
    //     app: 3
    //   };
    //   let customIndex = getApp().globalData.AddClientUrl("/unifined_order.html", wxChatPayParam, 'post');
    //   wx.request({
    //     url: customIndex.url,
    //     data: customIndex.params,
    //     header: getApp().globalData.headerPost,
    //     method: 'POST',
    //     success: function (res) {
    //       console.log(res.data);
    //       let PayStr = res.data;
    //       PayStr = '{' + PayStr + '}';
    //       let wechatPayStr = JSON.parse(PayStr);
    //       console.log(wechatPayStr);
    //       wx.requestPayment({
    //         'timeStamp': wechatPayStr.timeStamp,
    //         'nonceStr': wechatPayStr.nonceStr,
    //         'package': wechatPayStr.package,
    //         'signType': wechatPayStr.signType,
    //         'paySign': wechatPayStr.paySign,
    //         'success': function (res) {
    //           console.log('------成功--------');
    //           console.log(res);
    //           wx.showToast({
    //             title: '支付成功',
    //             icon: 'success',
    //             duration: 2000
    //           });
    //         },
    //         'fail': function (res) {
    //           console.log('------fail--------');
    //           console.log(res);
    //           wx.showToast({
    //             title: '支付失败',
    //             image: '/wxcomponents/images/icons/tip.png',
    //             duration: 2000
    //           });
    //         },
    //         'complete': function () {
    //           console.log('------complete--------');
    //           console.log(res);
    //           // getApp().globalData.navigateBack(2000);
    //           that.getData(that.listPage,'upload');
    //         }
    //       });
    //     }
    //   });
    // },
    cancelTaskFun:function(taskAttendId,taskId){
      let that = this
      let params={
          taskId:taskId,
          taskAttendId:taskAttendId
      }
      console.log("===params==",params)
      var customIndex = getApp().globalData.AddClientUrl("/wx_cancel_my_task_attended.html", params)
      getApp().globalData.showToastLoading('loading', true)
      wx.request({
        url: customIndex.url,
        header: getApp().globalData.header,
        success: function (res) {
          wx.hideLoading()
          console.log(res.data)
          let data=res.data.relateObj;
          if(res.data.errcode==0){
              wx.showToast({
                title: "取消成功！",
                icon:'success',
                duration: 1000
              });
              for(let i=0;i<that.taskList.length;i++){
                  if(that.taskList[i].id==taskAttendId){
                      let curItemData=JSON.parse(JSON.stringify(that.taskList[i]));
                      curItemData.status=data.status
                      that.taskList.splice(i,1,curItemData)
                  }
              }
          }else{
              wx.showToast({
                title: res.data.errMsg,
                image: '/wxcomponents/images/icons/tip.png',
                duration: 1000
              });
          }
          wx.hideLoading()
        },
        fail: function (res) {
          console.log("fail")
          wx.hideLoading()
          getApp().globalData.loadFail()
        }
      })
    },
    finishTaskFun:function(taskAttendId,taskId){
      let that = this
      let params={
          taskId:taskId,
          taskAttendId:taskAttendId
      }
      console.log("===params==",params)
      var customIndex = getApp().globalData.AddClientUrl("/wx_finished_task_attend.html", params)
      getApp().globalData.showToastLoading('loading', true)
      wx.request({
        url: customIndex.url,
        header: getApp().globalData.header,
        success: function (res) {
          wx.hideLoading()
          console.log(res.data)
          let data=res.data.relateObj;
          if(res.data.errcode==0){
              wx.showToast({
                title: "完成成功！",
                icon:'success',
                duration: 1000
              });
              for(let i=0;i<that.taskList.length;i++){
                  if(that.taskList[i].id==taskAttendId){
                      let curItemData=JSON.parse(JSON.stringify(that.taskList[i]));
                      curItemData.status=data.status
                      that.taskList.splice(i,1,curItemData)
                  }
              }
          }else{
              wx.showToast({
                title: res.data.errMsg,
                image: '/wxcomponents/images/icons/tip.png',
                duration: 1000
              });
          }
          wx.hideLoading()
        },
        fail: function (res) {
          console.log("fail")
          wx.hideLoading()
          getApp().globalData.loadFail()
        }
      })
    },
    bindTypeItem:function(index){
        let that=this;
        that.positionTab=index
        that.listPage.state=that.taskStateList[index].state
        that.getData(that.listPage,'upload');
    },
    /* 获取数据 */
    getData: function (param) {
      var that = this
      let params=Object.assign({},param,{
        // taskStatus:-1
      })
      console.log("===params==",params)
      var customIndex = getApp().globalData.AddClientUrl("/wx_my_task_attendeds.html", params)
      getApp().globalData.showToastLoading('loading', true)
      wx.request({
        url: customIndex.url,
        header: getApp().globalData.header,
        success: function (res) {
          wx.hideLoading()
          console.log(res.data)
          let data=res.data.relateObj.result
          that.listPage.pageSize = res.data.relateObj.pageSize
          that.listPage.page = res.data.relateObj.curPage
          that.listPage.totalSize = res.data.relateObj.totalSize
          let dataArr = that.taskList;
          let tagArray=[];
          for (let i = 0; i < data.length; i++) {
            if (data[i].tags && data[i].tags != '') {
              tagArray = JSON.parse(data[i].tags)
              data[i].tagArray = tagArray;
            }
            if (data[i].managerTags && data[i].managerTags != '') {
              tagArray = JSON.parse(data[i].managerTags)
              if(data[i].payedPrice>0){
                  tagArray.splice(tagArray.length,1,'已交定金')
              }
              data[i].managerTagArray = tagArray;
            }
          }
          console.log("===data====",data)
          if (param.page == 1) {
            dataArr = []
          }
          if (!data || data.length == 0) {
            that.setData({ taskList: null })
          } else {
            if (dataArr == null) { dataArr = [] }
            dataArr = dataArr.concat(data)
            that.setData({ taskList: dataArr })
          }
          wx.hideLoading()
        },
        fail: function (res) {
          console.log("fail")
          wx.hideLoading()
          getApp().globalData.loadFail()
        }
      })
    },
    /* 组件事件集合 */
    tolinkUrl: function (e) {
      console.warn("=======e=======", e);
      let linkUrl = e.currentTarget?e.currentTarget.dataset.url:e;
      getApp().globalData.linkEvent(linkUrl);
    },
    setData: function (obj) {
      let that = this;
      let keys = [];
      let val, data;
      Object.keys(obj).forEach(function (key) {
        keys = key.split('.');
        val = obj[key];
        data = that.$data;
        keys.forEach(function (key2, index) {
          if (index + 1 == keys.length) {
            that.$set(data, key2, val);
          } else {
            if (!data[key2]) {
              that.$set(data, key2, {});
            }
          }

          data = data[key2];
        });
      });
    }
  }
};
</script>
<style>
@import "./index.css";
</style>